/**
 * 添加或者修改页面
 */
var MemberSpecsInfoDlg = {
    data: {
        vipName: "",
        vipPic: "",
        vipLevel: "",
        vipPrice: "",
        vipLimited: ""
    }
};

layui.use(['form', 'admin', 'ax', 'upload', 'laydate', 'selectPlus'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var upload = layui.upload;
    var laydate = layui.laydate;
    var selectPlus = layui.selectPlus;

    //让当前iframe弹层高度适应
    admin.iframeAuto();

    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/memberSpecs/addItem", function (data) {
            Feng.success("添加成功！");
            window.location.href = Feng.ctxPath + '/memberSpecs'
        }, function (data) {
            Feng.error("添加失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });
    //普通图片上传
    upload.render({
        elem: '#picBtn'
        , url: Feng.ctxPath + '/system/uploads'
        , before: function (obj) {
            obj.preview(function (index, file, result) {
                $('#img1').attr('src', result);
            });
        }
        , done: function (res) {
            $("#vipPic").val(res.data.fileId);
            Feng.success(res.message);
        }
        , error: function () {
            Feng.error("上传图片失败！");
        }
    });
    //返回按钮
    $("#backupPage").click(function () {
        window.location.href = Feng.ctxPath + '/memberSpecs'
    });

});